package org.fing.edu.uy.esbadp.motor.init;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.fing.edu.uy.esbadp.motor.config.LoaderXMLConfig;
import org.fing.edu.uy.esbadp.motor.mbean.RegisterMBean;

public class InitializeMotorMonitor implements ServletContextListener {

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		RegisterMBean.getInstance().registerIMotorMonitorServicesMBean();
		//Load al xml configuration
		LoaderXMLConfig loader = new LoaderXMLConfig();
		loader.loadMonitoredEvents();
		loader.loadAdaptationRequirements();
		loader.loadStrategies();
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		RegisterMBean.getInstance().unRegisterIMotorMonitorServicesMBean();
	}
	
}
